<?php

/**
 * Description of ImageType
 *
 * @author hungnq
 */
class Core_Validate_ImageType extends Zend_Validate_Abstract
{

	const FALSE_EXTENSION = 1;
	protected $_validExtension = array();
	
	public function __construct($options)
	{
		$this->_validExtension = $options;
		$this->_messageTemplates = array(
			self::FALSE_EXTENSION => "File '%value%' has a false mime type"
		);
	}

	public function isValid($value, $file =null)
	{
		$extension = exif_imagetype($value);
		if(!in_array($extension, $this->_validExtension))
		{
			$this->_value = $file['name'];
			$this->_error(self::FALSE_EXTENSION);
			return false;
		}
		return true;
	}
	
	public function getMessages()
	{
		return $this->_messages;
	}

}

